package sdk.pay.model;

import android.content.Context;
import android.content.Intent;

import java.net.URISyntaxException;

import sdk.pay.basepay.UnifiedPay;
import sdk.pay.utils.PayExceptionUtil;

/**
 * Created by Administrator on 2017/6/2.
 */

public class IntentPay {
    public static void intentPay(Context context, String url, UnifiedPay.CallBack callBack) {
        try {
            Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setComponent(null);
            intent.setSelector(null);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } catch (URISyntaxException e) {
            e.printStackTrace();
            PayExceptionUtil.getInstance().saveExceptionFile("intentPay exception message = " + e.getMessage());
        } finally {
            if (null != callBack) {
                callBack.prepareLeave();
            }
        }
    }
}
